package com.dj.ms.support.mq;

import com.aliyun.openservices.ons.api.Message;
import com.aliyun.openservices.ons.api.MessageListener;
import com.aliyun.openservices.ons.api.order.MessageOrderListener;
import com.dj.common.DeJiSerializable;
import com.dj.ms.support.ConfigProcessor;
import com.dj.ms.support.plus.PlusDataSourceConfig;
import lombok.*;
import lombok.experimental.Accessors;

/**
 * <br>
 * <p>
 * -    mq参数处理
 * </p>
 *
 * <br>
 *
 * @author ZJG
 * @version 1.0
 * @date 2021/10/29 下午1:42
 */
@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
public class MQParameter extends DeJiSerializable {

    private ConsumeArgs consumeArgs;
    private SendArgs sendArgs;

    public static class Coordinator implements ConfigProcessor<MQParameter> {
        private final MQParameter mqParameter;

        public Coordinator() {
            this.mqParameter = new MQParameter();
        }

        public void consumeArgs(ConsumeArgs consume_args) {
            mqParameter.consumeArgs = consume_args;
        }

        public void sendArgs(SendArgs send_args) {
            mqParameter.sendArgs = send_args;
        }

        @Override
        public MQParameter process() {
            return mqParameter;
        }
    }

    @Setter
    @Getter
    @Builder
    @Accessors(chain = true)
    @AllArgsConstructor
    @NoArgsConstructor
    public static class ConsumeArgs {
        private String topic;
        private String tag;
        private MessageOrderListener orderListener;
        private MessageListener messageListener;
    }

    @Setter
    @Getter
    @Builder
    @Accessors(chain = true)
    @AllArgsConstructor
    @NoArgsConstructor
    public static class SendArgs {
        private Message message;
        private String shardingKey;
        private boolean async;
    }


}
